package com.wfh.utils;

import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.json.JSONUtil;

/**
 * @Title: CacheKeyUtil
 * @Author wangfenghuan
 * @Package com.wfh.aigenerator.utils
 * @Date 2025/8/13 20:18
 * @description:
 */
public class CacheKeyUtil {

    /**
     * 生成缓存key
     * @param object
     * @return
     */
    public static String getCacheKey(Object object){
        if (object == null){
            return DigestUtil.md5Hex("null");
        }
        // 先转化成json,在转化成md5
        String jsonStr = JSONUtil.toJsonStr(object);
        return DigestUtil.md5Hex(jsonStr);
    }

}
